<template>
	<view class="order-detail">
		<view class="my-list-detail" v-for="item in list" :key="item[0].id">
			<view class="ml-item">
				<view style="color: red;font-weight: 700;font-size: 40rpx;margin-bottom: 10rpx;">
					{{item[0].accidentName}}:
				</view>
				<view style="margin: 20rpx;" v-for="(data,index) in item" :key="index">
					<u-button style="font-weight: 700;" type="primary"
						@click="go_accidentNotice(data)">{{data.accidentContent}}</u-button>

				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {

		data() {
			return {
				orderNum: "",
				list: [],
				id: ''
			}
		},
		onLoad(e) {
			this.orderNum = e.orderNum
			this.id = e.id
			this.findAccidentNoticeSetPageList()
			uni.removeStorage({
				key: 'storage_accidentNotice',

			});

		},
		methods: {
			go_accidentNotice(e) {
				uni.setStorage({
					key: 'storage_accidentNotice',
					data: e,

				});
				uni.navigateTo({
					url: '/order-man/accidentNotice/accidentNotice?orderNum=' + this.orderNum + '&id=' +
						this.id
				})
			},
			findAccidentNoticeSetPageList(page) {
				let that = this;
				let ps = {
					page: {
						pageNum: 1,
						pageSize: 999,
					}
				}

				that.$u.api.findAccidentNoticeSetPageList(ps).then(res => {

					if (res && res.data) {
						let data = Object.values(res.data.list.reduce((acc, obj) => {
							const key = obj.accidentName; // 根据哪个字段来进行分组，这里使用id字段作为例子
							if (!acc[key]) acc[key] = []; // 如果当前分组不存在则创建一个空数组
							acc[key].push(obj); // 将当前对象添加到对应的分组
							return acc;
						}, {}));

						// that.list = data
						// console.log(data)
						let arr = []
						arr.push(data[9])
						arr.push(data[4])
						arr.push(data[1])
						arr.push(data[8])
						arr.push(data[0])
						arr.push(data[2])
						arr.push(data[3])
						arr.push(data[5])
						arr.push(data[6])
						arr.push(data[7])
						that.list = arr
					}

				});
			},

		}
	}
</script>

<style lang="less">
	.order-detail {
		/* #ifdef MP-WEIXIN */
		height: 100vh;
		overflow-y: auto;
		/* #endif */

		background: #efefef;
		padding: 20rpx;
	}
</style>